//
//  LoginVC.m
//  qwe
//
//  Created by 谢志振 on 16/8/11.
//  Copyright © 2016年 谢志振. All rights reserved.
//

#import "LoginVC.h"
#import "SDAutoLayout.h"
#import "RegisterOneVC.h"
#import "VDJConstant.h"
#import "ZMenuViewController.h"
#import "MainVC.h"
#import "UserVC.h"
@implementation LoginVC
- (void)viewDidLoad
{
    self.navigationController.navigationBarHidden = YES;
    [super viewDidLoad];
    
    [self baseUI];
    
}

#pragma mark - Event Response
- (void)onTapRegistButton
{
    [self.navigationController pushViewController:[[RegisterOneVC alloc]init] animated:YES];
}
- (void)onTapForgetButton
{
    
}
- (void)onTapRememberButton:(UIButton *)sender
{
    sender.selected = !sender.selected;
    
}
- (void)onTapLoginButton
{
    ZMenuViewController *menuVC = [[ZMenuViewController alloc] initWithRootViewController:[[MainVC alloc] init] leftViewController:[[UserVC alloc] init] rightViewController:nil];
    [self.navigationController pushViewController:menuVC animated:YES];
}
- (void)baseUI
{
    UIImageView * bg = [[UIImageView alloc]initWithFrame:self.view.bounds];
    bg.image = [UIImage imageNamed:@"登录背景"];
    [self.view addSubview:bg];
    
    UIButton * registBtn = [UIButton new];
    [registBtn setTitle:@"注册" forState:0];
    [registBtn setTitleColor:[UIColor whiteColor] forState:0];
    registBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [registBtn addTarget:self action:@selector(onTapRegistButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registBtn];
    CGFloat margin = 12;
    registBtn.sd_layout
    .rightSpaceToView(self.view,margin)
    .topSpaceToView(self.view,2*margin)
    .widthIs(30)
    .heightIs(15);
    
    //账号
    UIImageView * phoneImage = [UIImageView new];
    phoneImage.image = [UIImage imageNamed:@"手机号"];
    [self.view addSubview:phoneImage];
    
    UILabel * verticalLine = [UILabel new];
    verticalLine.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:verticalLine];
    
    UITextField * accountTF = [UITextField new];
    accountTF.borderStyle = UITextBorderStyleNone;
    accountTF.placeholder = @"请输入帐号";
    [accountTF setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    accountTF.textColor = [UIColor whiteColor];
    accountTF.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:accountTF];
    
    UILabel * horizontalLine = [UILabel new];
    horizontalLine.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:horizontalLine];
    
    horizontalLine.sd_layout.topSpaceToView(self.view,self.view.frame.size.height/2.f - 60).centerXEqualToView(self.view).heightIs(1).widthRatioToView(self.view,0.6f);
    phoneImage.sd_layout.bottomSpaceToView(horizontalLine,8).leftEqualToView(horizontalLine).heightIs(15).widthEqualToHeight();
    verticalLine.sd_layout.centerYEqualToView(phoneImage).leftSpaceToView(phoneImage,8).heightRatioToView(phoneImage,0.8f).widthIs(1);
    accountTF.sd_layout.centerYEqualToView(phoneImage).rightEqualToView(horizontalLine).heightRatioToView(phoneImage,1.f).leftSpaceToView(verticalLine,8);
    
    //密码
    UIImageView * pwImage = [UIImageView new];
    pwImage.image = [UIImage imageNamed:@"密码"];
    [self.view addSubview:pwImage];
    
    UILabel * verticalLine2 = [UILabel new];
    verticalLine2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:verticalLine2];
    
    UITextField * pwTF = [UITextField new];
    pwTF.secureTextEntry = YES;
    pwTF.borderStyle = UITextBorderStyleNone;
    pwTF.placeholder = @"请输入密码";
    [pwTF setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    pwTF.textColor = [UIColor whiteColor];
    pwTF.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:pwTF];
    
    UILabel * horizontalLine2 = [UILabel new];
    horizontalLine2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:horizontalLine2];
    
    horizontalLine2.sd_layout.topSpaceToView(horizontalLine,30 + 25 + 16).centerXEqualToView(self.view).heightIs(1).widthRatioToView(self.view,0.6f);
    pwImage.sd_layout.bottomSpaceToView(horizontalLine2,8).leftEqualToView(horizontalLine2).heightIs(15).widthEqualToHeight();
    verticalLine2.sd_layout.centerYEqualToView(pwImage).leftSpaceToView(pwImage,8).heightRatioToView(pwImage,0.8f).widthIs(1);
    pwTF.sd_layout.centerYEqualToView(pwImage).rightEqualToView(horizontalLine2).heightRatioToView(pwImage,1.f).leftSpaceToView(verticalLine2,8);

    //logo
    UIImageView * logo = [UIImageView new];
    logo.image = [UIImage imageNamed:@"logo"];
    [self.view addSubview:logo];
    logo.sd_layout.centerXEqualToView(horizontalLine).bottomSpaceToView(accountTF,30).widthIs(40).heightEqualToWidth();
    
    //忘记密码
    UIButton * forget = [UIButton new];
    [forget setTitle:@"忘记密码?" forState:0];
    forget.titleLabel.font = [UIFont systemFontOfSize:11];
    [forget addTarget:self action:@selector(onTapForgetButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:forget];
    forget.sd_layout.rightEqualToView(horizontalLine2).heightIs(15).widthIs(50).topSpaceToView(horizontalLine2,5);
    //记住密码
    UIButton * remember = [UIButton new];
    [remember setTitle:@"记住密码" forState:0];
    [remember setImage:[UIImage imageNamed:@"框"] forState:0];
    [remember setImage:[UIImage imageNamed:@"钩"] forState:UIControlStateSelected];
    remember.titleLabel.font = [UIFont systemFontOfSize:11];
    [remember addTarget:self action:@selector(onTapRememberButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:remember];
    remember.sd_layout.leftEqualToView(horizontalLine2).heightIs(15).widthIs(70).topSpaceToView(horizontalLine2,5);
    remember.imageView.sd_layout.leftEqualToView(remember).centerYEqualToView(remember).widthRatioToView(remember,0.2f).heightEqualToWidth();
    remember.titleLabel.sd_layout.rightEqualToView(remember).centerYEqualToView(remember).widthRatioToView(remember,0.7f).heightRatioToView(remember,1.f);
    
    //登陆按钮
    UIButton * login = [UIButton new];
    [login setTitle:@"登    陆" forState:0];
    [login setBackgroundImage:[UIImage imageNamed:@"登录按钮"] forState:0];
    [login setTitleColor:kGetColor(43, 130, 211) forState:0];
    login.titleLabel.font = [UIFont systemFontOfSize:16];
    [login addTarget:self action:@selector(onTapLoginButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:login];
    login.sd_layout.leftEqualToView(horizontalLine2).rightEqualToView(horizontalLine2).heightIs(40).topSpaceToView(remember,30);
    
}
@end
